<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="referrer" content="no-referrer" />
    <meta
            name="viewport"
            content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"
    />
    <link
            rel="stylesheet"
            href="https://at.alicdn.com/t/c/font_4755959_3wul6m83yfm.css"
    />
    <link rel="icon" type="image/x-icon" href="../img/logo.jpg" />
    <link rel="stylesheet" href="../style/public.css" />
    <link rel="stylesheet" href="./my-application.css" />
    <title>我的申请</title>
</head>
<body>
<nav>
    <div class="flex jc-sb aic bg-base p-10 head fixed w100p">
        <p class="f14 fff back">
            <i class="iconfont icon-arrow-left"></i><span>返回</span>
        </p>
        <p class="fff f22"><span>我的申请</span></p>
        <p class="search rel w100p">
            <i class="iconfont icon-sousuo f26 abs"> </i>
            <input type="text" placeholder="搜索" class="fff f16 pl-25" />
        </p>
    </div>
    <div style="height: 55px"></div>
</nav>
<main>
    <div id="my-apply" class="work">
        <!-- <div class="work-list flex bg-fff w100p">
          <ul class="list w100p">
            <li class="item w100p">
              <p class="flex jc-sb">
                <span>起重机维修电工（包食宿+年终奖）</span>
              </p>
              <p class="flex jc-sb">
                <span class="sc">6000-8000元/月</span>
                <span class="f12 c888">50分钟前</span>
              </p>
              <p class="flex jc-sb aic bb2 pb-20">
                <span class="condition fcc f12">地区不限</span>
                <span class="condition fcc f12">经验不限</span>
                <span class="condition fcc f12">学历不限</span>
                <button class="btn fff">取消申请</button>
              </p>
              <p class="company flex aic">
                <img
                        src="https://talent-js-nantong.oss-cn-shanghai.aliyuncs.com/user-upload-image/202112/1701679798575.jpg-z200"
                        alt=""
                />
                <span class="f14 ml-10">航宇结构件有限公司</span>
                <span class="f12 sc ml-10">认证</span>
              </p>
            </li>
          </ul>
        </div> -->
    </div>
   
</main>
<div class="fcc mt-20 f20 mb-20 c666"><span>没有更多了</span></div>
<script src="../js/jquery.js"></script>
<script src="../js/axios.js"></script>
<script>
    var apply = {
        getData() {
            var url = `http://localhost:3000/apply?userId=${localStorage.userId}`;
            axios.get(url).then(function (res) {
                apply.render(res.data);
                apply.delData(res.data);
            });
        },
        render(list) {
            var htmlStr = "";
            list.forEach(function (item) {
                htmlStr += `
          <div   class="work-list flex bg-fff w100p">
          <ul class="list w100p">
            <li class="item w100p">
              <a href="./job-details.html?id=${item.id}" class="flex jc-sb">
                <span>${item.workTitle}</span>
              </a>
              <p class="flex jc-sb">
                <span class="sc">${item.price}</span>
                <span class="f12 c888">申请时间：${item.time}</span>
              </p>
              <p class="flex jc-sb aic bb2 pb-20">
                <span class="condition fcc f12">${item.conditionAddress}</span>
                <span class="condition fcc f12">${item.conditionExperience}</span>
                <span class="condition fcc f12">${item.conditionEdu}</span>
                <button class="btn fff" data-id="${item.id}">取消申请</button>
              </p>
              <p class="company flex aic">
                <img
                        src="${item.imgUrl}"
                        alt=""
                />
                <span class="f14 ml-10">${item.companyName}</span>
                <span class="f12 sc ml-10">认证</span>
              </p>
            </li>
          </ul>
        </div>
          `;
                $("#my-apply").html(htmlStr);
            });
        },
        delData(data) {
            $(".btn").click(function () {
                var id = $(this).data('id');
                var url = "http://localhost:3000/apply/" + id;
                axios
                   .delete(url)
                   .then(function (res) {
                      
                       alert("取消成功");
                    })
                   .catch(function (err) {
                        console.error("删除失败", err);
                    });
                    $(this).parent().parent().parent().parent().remove();
            });
          
        },
        
    };
    // 返回上一层
    $(document).ready(function () {
        $(".back").click(function () {
            history.back();
        });
    });
    apply.getData();
</script>
</body>
</html>